package com.bj.zspace.cat.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ConfigurableBootstrapContext;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringApplicationRunListener;

/**
 * @Author:liuwenqing
 * @Date:2024/11/12 21:09
 * @Description:
 **/

public class CatInitializerListener implements SpringApplicationRunListener {

    private static final Logger logger = LoggerFactory.getLogger(CatInitializerListener.class);

    private SpringApplication application;
    private String[] args;

    public CatInitializerListener(SpringApplication application, String[] args) {
        this.application = application;
        this.args = args;
    }

    @Override
    public void starting(ConfigurableBootstrapContext bootstrapContext) {
        logger.info("CatInitializerListener onApplicationEvent starting");
        logger.info("CAT_HOME:{}", Thread.currentThread().getContextClassLoader().getResource("").getPath());
        System.setProperty("CAT_HOME", Thread.currentThread().getContextClassLoader().getResource("").getPath());
    }
}
